package com.bw.liuyushan.liuyushan20210904.Adapter;

import android.view.View;

import com.bw.liuyushan.liuyushan20210904.Entity.VideoBean;
import com.bw.liuyushan.liuyushan20210904.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * Liuyushan20210904
 * file name is : VideoAdapter
 * created by Ender on 2021/9/4 10:01.
 * author : 刘雨杉
 * Describe:
 */
public class VideoAdapter extends BaseQuickAdapter<VideoBean.DataBean, BaseViewHolder> {
    int i=0;
    public VideoAdapter(@Nullable List<VideoBean.DataBean> data) {
        super(R.layout.itemvideorv, data);
        addChildClickViewIds(R.id.download);//添加子布局控件
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, VideoBean.DataBean dataBean) {
        StandardGSYVideoPlayer stands = baseViewHolder.findView(R.id.stand);
        stands.setUp(dataBean.getVideopath(),false,dataBean.getCaption());
        if (i==0){
            stands.startPlayLogic();
            i++;//自动播放
        }
        //开启全屏功能
        stands.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                stands.startWindowFullscreen(getContext(),true,true);
            }
        });
    }

}
